﻿using System;
using System.Configuration;
using System.IO;

namespace WriteLog
{
    /// <summary>
    /// 描述了日志文件的存储规则
    /// </summary>
    internal class TxtLogFileRule : ConfigurationElement
    {
        /// <summary>
        /// 获取文件规则中关于文件名称的定义
        /// Time   用时间表示文件名称
        /// Guid   用Guid表示文件名称
        /// </summary>
        [ConfigurationProperty("FileNameRule", IsRequired = true)]
        public FileNameRule NameRule
        {
            get
            {
                return (FileNameRule)base["FileNameRule"];
            }
        }
        /// <summary>
        /// 获取份文件存储的规则
        /// AssignSize   指定大小
        /// PerItem   每天一个
        /// HourItem   每小时一个
        /// </summary>
        [ConfigurationProperty("FilePartRule", IsRequired = true)]
        public FilePartRule PartRule
        {
            get
            {
                return (FilePartRule)base["FilePartRule"];
            }
        }

        /// <summary>
        /// 表示限定文件的大小
        /// 当FilePartRule = 0 时有效
        /// </summary>
        [ConfigurationProperty("FileSize", IsRequired = false)]
        internal long FileSize
        {
            get
            {
                return long.Parse(base["FileSize"].ToString());
            }
        }

    }
}
